# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

# Initial PKGBUILD from AUR.
# Old Maintainer: Tony Lambiris <tony@libpcap.net>

pkgname=lte-cell-scanner
pkgver=26.e7f71cb
pkgrel=1
epoch=1
pkgdesc='An OpenCL accelerated TDD/FDD LTE Scanner.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-radio' 'blackarch-mobile' 'blackarch-scanner')
url='https://github.com/JiaoXianjun/LTE-Cell-Scanner'
license=('GPL')
depends=('git')
makedepends=('cmake' 'hackrf' 'fftw' 'itpp' 'boost' 'boost-libs' 'bladerf')
source=("$pkgname::git+https://github.com/JiaoXianjun/LTE-Cell-Scanner")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

prepare() {
	cd $pkgname

	mkdir -p build
}

build() {
	cd $pkgname

	cd build

	cmake ../ \
    -DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE=ON \
		-DUSE_HACKRF=1 \
		-DUSE_BLADERF=1 \
		-DUSE_OPENCL=0 # opencl segfaults in some cases

  make
}

package() {
  cd $pkgname

  cd build

	make DESTDIR="$pkgdir" install
}

